package vn.igolf;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;

import vn.igolf.gui.ScreenMapGUI;

public class MainClass  {
    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
    	
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                MainGUI.createAndShowGUI();
            }
        });
    }
}


class MainGUI extends JPanel  {
	

	private JLayeredPane layeredPane;
	private JLabel textLabel;
	
    public MainGUI()    {
        setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

        //Create and set up the layered pane.
        layeredPane = new JLayeredPane();
        layeredPane.setPreferredSize(new Dimension(1013, 636+30));
               
        ScreenMapGUI screenMapGUI = new ScreenMapGUI();
        
        layeredPane.add(screenMapGUI.mapLabel, new Integer(1), 0);
//        layeredPane.add(screenMapGUI.dukeLabel, new Integer(4), 0);
        layeredPane.add(screenMapGUI.mark, new Integer(5), 0);
        
        textLabel = createColoredLabel("Minh Dinh", Color.WHITE, new Point(20,636));
        layeredPane.add(textLabel,new Integer(3), 0);
        
        add(layeredPane);
    }

    //Create and set up a colored label.
    private JLabel createColoredLabel(String text,
                                      Color color,
                                      Point origin) {
        JLabel label = new JLabel(text);
        label.setVerticalAlignment(JLabel.TOP);
        label.setHorizontalAlignment(JLabel.CENTER);
        label.setOpaque(true);
        label.setBackground(color);
        label.setForeground(Color.black);
        label.setBorder(BorderFactory.createLineBorder(Color.black));
        label.setBounds(origin.x, origin.y, 140, 30);
        return label;
    }

    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
    public static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame("LayeredPaneDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Create and set up the content pane.
        JComponent newContentPane = new MainGUI();
        newContentPane.setOpaque(true); //content panes must be opaque
        frame.setContentPane(newContentPane);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }
}
